package com.yuanshuai.controller;

import com.yuanshuai.MyDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//Rest模式
@RestController
@RequestMapping("/books")
public class BookController {
    @Value("${likes[1].name}")
    private String name;

    @Value("${dir1}")
    private String dir;
    // 取出全部数据
    @Autowired
    private Environment environment;

    @Autowired
    private MyDataSource dataSource;

    @GetMapping
    public String getById(){
        System.out.println("springboot is running...");
        System.out.println(name);
        System.out.println(dir);

        System.out.println(environment.getProperty("dir1"));

        System.out.println(dataSource);
        return "springboot is running1...";
    }

}
